package com.csii.mobilebanking.user;

import java.util.List;

import com.csii.mobilebanking.R;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

/**
 * Copyright (C) 2010,Under the supervision of China Telecom Corporation Limited
 * Guangdong Research Institute The New Vphone Project
 * 
 * @Author fonter.yang
 * @Create date��2010-10-11
 * 
 */
public class GridAdapter extends BaseAdapter {

	private class GridHolder {
		TextView appName;
	}
	private Context context;
	private List<String> mList;
	private LayoutInflater mInflater;

	public GridAdapter(Context c, List<String> list) {
		this.context = c;
		this.mList = list;
	}

	public int getCount() {
		return mList.size();
	}

	@Override
	public Object getItem(int index) {

		return mList.get(index);
	}

	@Override
	public long getItemId(int index) {
		return index;
	}

	@Override
	public View getView(int index, View convertView, ViewGroup parent) {
		GridHolder holder;
		if (convertView == null) {
			mInflater = (LayoutInflater) context
					.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			convertView = mInflater.inflate(R.layout.gridview_item, null);
			holder = new GridHolder();
			holder.appName = (TextView) convertView.findViewById(R.id.itemText);
			convertView.setTag(holder);

		} else {
			holder = (GridHolder) convertView.getTag();

		}
		String info = mList.get(index);
		if (info != null) {
			holder.appName.setText(info);
		}
		return convertView;
	}

}
